package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AdminPumpRecord;
import com.ruoyi.system.service.IAdminPumpRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 抽水记录Controller
 * 
 * @author ruoyi
 * @date 2020-11-13
 */
@RestController
@RequestMapping("/system/AgentPumpRecord")
public class AdminPumpRecordController extends BaseController
{
    @Autowired
    private IAdminPumpRecordService adminPumpRecordService;

    /**
     * 查询抽水记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:AgentPumpRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdminPumpRecord adminPumpRecord)
    {
        startPage();
        List<AdminPumpRecord> list = adminPumpRecordService.selectAdminPumpRecordList(adminPumpRecord);
        return getDataTable(list);
    }

    /**
     * 导出抽水记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:AgentPumpRecord:export')")
    @Log(title = "抽水记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdminPumpRecord adminPumpRecord)
    {
        List<AdminPumpRecord> list = adminPumpRecordService.selectAdminPumpRecordList(adminPumpRecord);
        ExcelUtil<AdminPumpRecord> util = new ExcelUtil<AdminPumpRecord>(AdminPumpRecord.class);
        return util.exportExcel(list, "AgentPumpRecord");
    }

    /**
     * 获取抽水记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:AgentPumpRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adminPumpRecordService.selectAdminPumpRecordById(id));
    }

    /**
     * 新增抽水记录
     */
    @PreAuthorize("@ss.hasPermi('system:AgentPumpRecord:add')")
    @Log(title = "抽水记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdminPumpRecord adminPumpRecord)
    {
        return toAjax(adminPumpRecordService.insertAdminPumpRecord(adminPumpRecord));
    }

    /**
     * 修改抽水记录
     */
    @PreAuthorize("@ss.hasPermi('system:AgentPumpRecord:edit')")
    @Log(title = "抽水记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdminPumpRecord adminPumpRecord)
    {
        return toAjax(adminPumpRecordService.updateAdminPumpRecord(adminPumpRecord));
    }

    /**
     * 删除抽水记录
     */
    @PreAuthorize("@ss.hasPermi('system:AgentPumpRecord:remove')")
    @Log(title = "抽水记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adminPumpRecordService.deleteAdminPumpRecordByIds(ids));
    }
}
